home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_PICT / Source / CommentedPSCode / Rectangles < prev    next >
Text File  |  1995-06-12  |  4KB  |  175 lines

  1. %BEGIN Rectangles
  2.  
  3. % Copyright (C) 1993 David John Burrowes
  4. % Distributed under terms of GNU General Public License.
  5. % See COPYING.text in Convert PICT's CommentedPSCode for a copy
  6.  
  7. %%%%%%%%%%%%%
  8. %    Name:    rectpath
  9. %    Syntax:    t l b r rectpath -
  10. %    About:    Given the bounds of the rectangle, build a path describing the outside
  11. %            edge of the rectangle.
  12. %            Note: defines new values for last* values in the process
  13. %%%%%%%%%%%%%
  14. /rectpath
  15. {
  16.     /lastright exch def
  17.     /lastbottom exch def
  18.     /lastleft exch def
  19.     /lasttop exch def
  20.  
  21.     newpath
  22.         lastleft lasttop moveto
  23.         lastright lasttop lineto
  24.         lastright lastbottom lineto
  25.         lastleft lastbottom lineto
  26.     closepath
  27. }
  28. def
  29.  
  30. %%%%%%%%%%%%%
  31. %    Name:    frameRect            [0030]
  32. %    Syntax:    t l b r frameRect -
  33. %    About:    Given the bounds of the rectangle, build a pair of paths, one forming the
  34. %            outside edge of the framed rectagle, and one the inside.  Fill between then.
  35. %            Note: defines new values for last* values in the process
  36. %%%%%%%%%%%%%
  37. /frameRect
  38. {
  39.     /lastright exch  def
  40.     /lastbottom exch  def
  41.     /lastleft exch def
  42.     /lasttop exch def
  43.     %
  44.     %    only do this if the pen sizes are > 0
  45.     %
  46.     penWidth 0 gt
  47.     penHeight 0 gt
  48.     and
  49.     {
  50.         gsave
  51.             penPattern usePattern
  52.             newpath
  53.                 lastleft lasttop moveto
  54.                 lastright lasttop lineto
  55.                 lastright  lastbottom  lineto
  56.                 lastleft lastbottom lineto
  57.             closepath
  58.                 lastleft penWidth add    lasttop penHeight add   moveto
  59.                 lastleft penWidth add   lastbottom penHeight sub   lineto
  60.                 lastright penWidth sub   lastbottom penHeight sub   lineto
  61.                 lastright penWidth sub   lasttop penHeight add   lineto
  62.             closepath
  63.             fill
  64.         grestore
  65.     }
  66.     if
  67. }
  68. def
  69.  
  70. %%%%%%%%%%%%%
  71. %    Name:    paintRect            [0031]
  72. %    Syntax:    t l b r paintRect -
  73. %    About:    Paints the rectangle formed by the bounds we are passed.
  74. %%%%%%%%%%%%%
  75. /paintRect
  76. {
  77.     gsave
  78.         penPattern usePattern
  79.         rectpath
  80.         fill
  81.     grestore
  82. } def
  83.  
  84. %%%%%%%%%%%%%
  85. %    Name:    invertRect            [0032]
  86. %    Syntax:    t l b r invertRect -
  87. %    About:    Erases the rectangle formed by the bounds we are passed.
  88. %            Note: erasing always means filling with the background pattern
  89. %%%%%%%%%%%%%
  90. /eraseRect
  91. {
  92.     gsave
  93.         backPattern usePattern
  94.         rectpath
  95.         fill
  96.     grestore
  97. }
  98. def
  99.  
  100. %%%%%%%%%%%%%
  101. %    Name:    invertRect            [0033]
  102. %    Syntax:    t l b r invertRect -
  103. %    About:    Call rectpath to properly consume arguments, but do nothing since
  104. %            we don't know how to invert in PS.
  105. %%%%%%%%%%%%%
  106. /invertRect
  107. {
  108.     gsave
  109.         rectpath
  110.     grestore
  111. }
  112. def
  113.  
  114. %%%%%%%%%%%%%
  115. %    Name:    fillRect                [0034]
  116. %    Syntax:    t l b r fillRect -
  117. %    About:    Fills the path formed by the rectangle bounds we are passed
  118. %%%%%%%%%%%%%
  119. /fillRect
  120. {
  121.     gsave
  122.         fillPattern usePattern
  123.         rectpath
  124.         fill
  125.     grestore
  126. }
  127. def
  128.  
  129. %%%%%%%%%%%%%
  130. %    Name:    frameSameRect        [0038]
  131. %    Syntax:    - frameSameRect -
  132. %    About:    Frames the last rectangle used
  133. %%%%%%%%%%%%%
  134. /frameSameRect
  135.     { lasttop lastleft lastbottom lastright frameRect }
  136. def
  137.  
  138. %%%%%%%%%%%%%
  139. %    Name:    paintSameRect        [0039]
  140. %    Syntax:    - paintSameRect -
  141. %    About:    paints the last rectangle used
  142. %%%%%%%%%%%%%
  143. /paintSameRect
  144.     { lasttop lastleft lastbottom lastright paintRect }
  145. def
  146.  
  147. %%%%%%%%%%%%%
  148. %    Name:    eraseSameRect        [003A]
  149. %    Syntax:    - eraseSameRect -
  150. %    About:    Erases the last rectangle used
  151. %%%%%%%%%%%%%
  152. /eraseSameRect
  153.     { lasttop lastleft lastbottom lastright eraseRect }
  154. def
  155.  
  156. %%%%%%%%%%%%%
  157. %    Name:    invertSameRect        [003B]
  158. %    Syntax:    - invertSameRect -
  159. %    About:    Inverts the last rectangle used
  160. %%%%%%%%%%%%%
  161. /invertSameRect
  162.     { lasttop lastleft lastbottom lastright invertRect }
  163. def
  164.  
  165. %%%%%%%%%%%%%
  166. %    Name:    fillSameRect            [003C]
  167. %    Syntax:    - fillSameRect -
  168. %    About:    Fills the last rectangle used
  169. %%%%%%%%%%%%%
  170. /fillSameRect
  171.     { lasttop lastleft lastbottom lastright fillRect }
  172. def
  173.  
  174. %END Rectangles
  175.